#ifndef DISKSERVICES_H_
#define DISKSERVICES_H_


#include "../physicalDisk/PhysicalDisk.h"
#include "DataBlock.h"
#include "Inode.h"
#include <string>
#include <map>

using namespace std;

class DiskServices {

private:
	map<int,Inode*> allocatedInodes;
	PhysicalDisk physicalDisk;

	void createInodeFromDisk(int inodeOffset);

public:
	DiskServices(int diskSizeInBytes, int dataBlockSize, int numberOfInodes);
	DiskServices();
	virtual ~DiskServices();
	int getBlockSize();
	int allocateInode();
	void incHardLinksNum (int inode);
	void decHardLinksNum (int inode);
	void freeInode(int inode);
	void resetInode(int inode);
	int allocateDataBlock();
	void freeDataBlock (int dblock);
	char getInodeType (int inode);
	void setInodeType (int inode, char filetype);
	int getDataBlock (int inode, int i);
	bool setDataBlock (int inode, int i, int dblockNum);
	int readBlock (int dblockNum, unsigned char buf[]);
	int writeBlock (int dblockNum, unsigned char *newData);
	int getFileSize (int inode);
	void setFileSize (int inode, int newSize);

	//on an error, every function should return an appropriate error code in stderr
};

#endif /* DISKSERVICES_H_ */
